<?php
include('inc_head.php');
$tag=$wu->request_string('tag');
if(!$tag) die('参数无效');
if($wu->request_string("act")=='del' && request_int("id")){
	$db->delete('tgeneraldata',"ID=".request_int("id"));
	$wu->redirect("删除成功",'?tag='.$tag);	
}
?>
<div style=" margin:5px;"><a href='generaldata_edit.php?tag=<?php echo $tag; ?>' class="btn btn-info">新增</a></div>
<table>
    <thead>
        <tr><th>序号</th><th>名称</th><th>分类</th><th>操作</th></tr>
    </thead>
    <tbody>
    	<?php
		$rs=$db->fetch_all("select * from tgeneraldata where ParentID=0 and ExTags='$tag'");
		if($rs){			
			foreach($rs as $row){			
				echo '<tr><td>1</td><td>'.$row['Name'].'</td><td>&nbsp;</td><td><a href="generaldata_edit.php?tag='.$tag.'&id='.$row['ID'].'">编辑</a> <a href="###" onclick="if(confirm(\'您确定要删除吗?\')){location.href=\'?tag='.$tag.'&act=del&id='.$row['ID'].'\';}">删除</a> <a href="generaldata_edit.php?tag='.$tag.'&pid='.$row['ID'].'">新增</a></td></tr>';
				$rs2=	$db->fetch_all("select * from tgeneraldata where ParentID=".$row['ID']);
				if($rs2){
					foreach($rs2 as $row2){			
						echo '<tr><td>1</td><td>--'.$row2['Name'].'</td><td>&nbsp;</td><td><a href="generaldata_edit.php?$tag='.$tag.'&id='.$row2['ID'].'">编辑</a> <a href="###" onclick="if(confirm(\'您确定要删除吗?\')){location.href=\'?act=del&tag='.$tag.'&id='.$row2['ID'].'\';}">删除</a></td></tr>';
						
					}
				}
			}
		}
		?>
    </tbody>
    <tfoot>
        <tr class="warning"><td colspan="8">-</td></tr>
    </tfoot>
</table>
<?php
	include('inc_foot.php');
?>